import os

path1 = '/Users/cai/Documents/sxw/sxw/apk/driverphone'
path2 = '/Users/cai/Documents/sxw/sxw/apk/pad'


def modify_name(path, splitstr='AMA', newprefix='sxwdriverphone_'):
    namelist = os.listdir(path)
    for name in namelist:
        if name.startswith('.'):
            continue
        index = name.index(splitstr)
        if index == -1:
            continue

        newname = newprefix + name[index:]

        newfullpath = "%s/%s" % (path, newname)
        oldfullpath = "%s/%s" % (path, name)

        print(oldfullpath)
        print(newfullpath)
        print("*" * 100)
        print()
        modify_file_name(oldfullpath, newfullpath)


def modify_file_name(oldpath, newpath):
    os.rename(oldpath, newpath)


# modify_name(path1)
modify_name(path2, 'WPA', 'sxwpad_')
